home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / stevi69s.zip / TERM.H < prev    next >
C/C++ Source or Header  |  1990-04-23  |  7KB  |  178 lines

  1. /* $Header: /nw/tony/src/stevie/src/RCS/term.h,v 1.7 89/08/01 17:25:18 tony Exp $
  2.  *
  3.  * System-dependent escape sequence definitions.
  4.  */
  5.  
  6. #ifdef    TERMCAP
  7.  
  8. extern char *T_EL;        /* erase the entire current line */
  9. extern char *T_IL;        /* insert one line */
  10. extern char *T_DL;        /* delete one line */
  11. extern char *T_SC;        /* save the cursor position */
  12. extern char *T_ED;        /* erase display (may optionally home cursor) */
  13. extern char *T_RC;        /* restore the cursor position */
  14. extern char *T_CI;        /* invisible cursor (very optional) */
  15. extern char *T_CV;        /* visible cursor (very optional) */
  16.  
  17. extern char *T_CM;        /* cursor motion string */
  18.  
  19. #else
  20.  
  21. /*
  22.  * This file contains the machine dependent escape sequences that
  23.  * the editor needs to perform various operations. Some of the sequences
  24.  * here are optional. Anything not available should be indicated by
  25.  * a null string. In the case of insert/delete line sequences, the
  26.  * editor checks the capability and works around the deficiency, if
  27.  * necessary.
  28.  *
  29.  * Currently, insert/delete line sequences are used for screen scrolling.
  30.  * There are lots of terminals that have 'index' and 'reverse index'
  31.  * capabilities, but no line insert/delete. For this reason, the editor
  32.  * routines s_ins() and s_del() should be modified to use 'index'
  33.  * sequences when the line to be inserted or deleted line zero.
  34.  */
  35.  
  36. /*
  37.  * The macro names here correspond (more or less) to the actual ANSI names
  38.  */
  39.  
  40. #ifdef    ATARI
  41. #ifdef    MINIX
  42.  
  43. #define    T_EL    "\033[2K"    /* erase the entire current line */
  44. #define    T_IL    "\033[L"    /* insert one line */
  45. #define    T_DL    "\033[M"    /* delete one line */
  46. #define    T_SC    "\0337"        /* save the cursor position */
  47. #define    T_ED    "\033[2J"    /* erase display (may optionally home cursor) */
  48. #define    T_RC    "\0338"        /* restore the cursor position */
  49. #define    T_CI    ""        /* invisible cursor (very optional) */
  50. #define    T_CV    ""        /* visible cursor (very optional) */
  51.  
  52. #else
  53.  
  54. #define    T_EL    "\033l"        /* erase the entire current line */
  55. #define    T_IL    "\033L"        /* insert one line */
  56. #define    T_DL    "\033M"        /* delete one line */
  57. #define    T_SC    "\033j"        /* save the cursor position */
  58. #define    T_ED    "\033E"        /* erase display (may optionally home cursor) */
  59. #define    T_RC    "\033k"        /* restore the cursor position */
  60. #define    T_CI    "\033f"        /* invisible cursor (very optional) */
  61. #define    T_CV    "\033e"        /* visible cursor (very optional) */
  62.  
  63. #endif
  64. #endif
  65.  
  66. #ifdef    UNIX
  67. /*
  68.  * The following sequences are hard-wired for ansi-like terminals. To get
  69.  * termcap support, define TERMCAP in env.h and these sequences go away.
  70.  */
  71. #define    T_EL    "\033[2K"    /* erase the entire current line */
  72. #define    T_IL    "\033[L"    /* insert one line */
  73. #define    T_DL    "\033[M"    /* delete one line */
  74. #define    T_ED    "\033[2J"    /* erase display (may optionally home cursor) */
  75. #define    T_SC    "\0337"        /* save the cursor position */
  76. #define    T_RC    "\0338"        /* restore the cursor position */
  77. #define    T_CI    ""        /* invisible cursor (very optional) */
  78. #define    T_CV    ""        /* visible cursor (very optional) */
  79. #endif
  80.  
  81. #ifdef    OS2
  82. /*
  83.  * The OS/2 ansi console driver is pretty deficient. No insert or delete line
  84.  * sequences. The erase line sequence only erases from the cursor to the end
  85.  * of the line. For our purposes that works out okay, since the only time
  86.  * T_EL is used is when the cursor is in column 0.
  87.  *
  88.  * The insert/delete line sequences marked here are actually implemented in
  89.  * the file os2.c using direct OS/2 system calls. This makes the capability
  90.  * available for the rest of the editor via appropriate escape sequences
  91.  * passed to outstr().
  92.  */
  93. #define    T_EL    "\033[K"    /* erase the entire current line */
  94. #define    T_IL    "\033[L"    /* insert one line - fake (see os2.c) */
  95. #define    T_DL    "\033[M"    /* delete one line - fake (see os2.c) */
  96. #define    T_ED    "\033[2J"    /* erase display (may optionally home cursor) */
  97. #define    T_SC    "\033[s"    /* save the cursor position */
  98. #define    T_RC    "\033[u"    /* restore the cursor position */
  99. #define    T_CI    ""        /* invisible cursor (very optional) */
  100. #define    T_CV    ""        /* visible cursor (very optional) */
  101. #endif
  102.  
  103.  
  104. #ifdef    DOS
  105. /*
  106.  * DOS sequences
  107.  *
  108.  * Some of the following sequences require the use of the "nansi.sys"
  109.  * console driver. The standard "ansi.sys" driver doesn't support
  110.  * sequences for insert/delete line.
  111.  */
  112. #define    T_EL    "\033[K"    /* erase the entire current line */
  113. #define    T_IL    "\033[L"    /* insert line (requires nansi.sys driver) */
  114. #define    T_DL    "\033[M"    /* delete line (requires nansi.sys driver) */
  115. #define    T_ED    "\033[2J"    /* erase display (may optionally home cursor) */
  116. #define    T_SC    "\033[s"    /* save the cursor position */
  117. #define    T_RC    "\033[u"    /* restore the cursor position */
  118. #define    T_CI    ""        /* invisible cursor (very optional) */
  119. #define    T_CV    ""        /* visible cursor (very optional) */
  120. #endif
  121.  
  122. #endif
  123.  
  124. /*
  125.  * Machine-variant screen handling definitions.
  126.  *
  127.  * Define some macros which for invoking screen functions, whether by
  128.  * callling a bios function or outputting an escape sequence to be
  129.  * interpreted by a PC console driver or terminal.
  130.  *
  131.  * At this writing, not all of Stevie has been converted to use these
  132.  * macros.  So far, only DOS and PC BIOS versions are completely converted.
  133.  * Other versions are partly converted (because of changes I made in Stevie's
  134.  * common code), but they have not been tested.  I'll convert others which I'm
  135.  * in a position to test, but I'll leave any I can't test alone.  Hopefully,
  136.  * this will minimize any damage to working versions which I can't test. -LAS
  137.  */
  138.  
  139. #ifdef BIOS
  140.  
  141. #define    CANDL        TRUE        /* Can delete lines */
  142. #define    CANIL        TRUE        /* Can insert lines */
  143. #define    CLEOL        bios_t_el()    /* Erase to end-of-line */
  144. #define    CLS        bios_t_ed()    /* Erase entire display */
  145. #define    CRTDL(r,l)    bios_t_dl(r,l)    /* Delete lines from display */
  146. #define    CRTIL(r,l)    bios_t_il(r,l)    /* Insert lines in display */
  147. #define    CUROFF        bios_t_ci()    /* Make cursor invisible */
  148. #define    CURON        bios_t_cv()    /* Make cursor visible */
  149. #define    RESCUR        bios_t_rc()    /* Restore saved cursor position */
  150. #define    SAVCUR        bios_t_sc()    /* Save cursor position */
  151.  
  152. #else        /* Not BIOS */
  153.  
  154. #define    CANDL        (T_DL[0]!='\0')    /* Determine if can delete lines */
  155. #define    CANIL        (T_IL[0]!='\0')    /* Determine if can insert lines */
  156. #define    CLEOL        outstr(T_EL)    /* Erase to end-of-line */
  157. #define    CLS        outstr(T_ED)    /* Erase entire display */
  158. #define    CRTDL(r,l)    DO_DL(r,l)    /* Delete lines from display */
  159. #define    CRTIL(r,l)    DO_IL(r,l)    /* Insert lines in display */
  160. #define    CUROFF        outstr(T_CI)    /* Make cursor invisible */
  161. #define    CURON        outstr(T_CV)    /* Make cursor visible */
  162. #define    RESCUR        outstr(T_RC)    /* Restore saved cursor position */
  163. #define    SAVCUR        outstr(T_SC)    /* Save cursor position */
  164.  
  165. #define    DO_DL(r,l) {\
  166.     int __xx_knt = l;\
  167.     while (__xx_knt-- > 0) {outstr(T_DL);}\
  168. }
  169.  
  170. #define    DO_IL(r,l) {\
  171.     int __xx_knt = l;\
  172.     while (__xx_knt-- > 0) {outstr(T_IL);}\
  173. }
  174.  
  175. #endif        /* Not BIOS */
  176.  
  177.  
  178.